﻿using System;
using System.Web.UI;
using System.Threading;
using System.Globalization;
using System.Web.UI.WebControls;
using Enums;
using Vallejos.Negocio;

public partial class SiteMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            CargarValores();
    }

    private void CargarValores()
    {
         var negocio = (NegocioFacade)Session[VariablesDeSesion.NegocioFacade.ToString()];
         if (negocio.Persona != null)
         {
             lblUsuarioActivo.Text = negocio.Persona.Usuario.Login;
         }
         else
         {
             lnkDesconectarse.Visible = false;
             lblUsuarioActivo.Text = string.Empty;
         }
    }

   
    protected void btnArg_Click(object sender, ImageClickEventArgs e)
    {
        CambiarIdioma("es-AR");
    }
    protected void btnUs_Click(object sender, ImageClickEventArgs e)
    {
        CambiarIdioma("en-US");
    }

    protected void CambiarIdioma(String idioma)
    {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(idioma);
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(idioma);
    }

    protected void lnkDesconectarse_Click(object sender, EventArgs e)
    {
        var negocio = (NegocioFacade)Session[VariablesDeSesion.NegocioFacade.ToString()];
        negocio.Desconectarse();
    }
}
